package com.matt.foundation.dto;

import com.matt.foundation.utils.DateUtil;
import lombok.Data;

import java.util.List;
import java.util.Optional;


/**
 * *******************************
 * Created by Ron.
 * form com.matt
 * on 2018/10/9
 * *******************************
 */
@Data
public class WorkDayDTO {

    private Long date;

    private Boolean isWorkDay;

    private Boolean isWeekEnd;

    public static Boolean dayIsWorkday(String day, List<WorkDayDTO> list){
        Optional<WorkDayDTO> optional = list.stream().filter(o-> DateUtil.millisToDateTime(o.getDate(), "yyyy-MM-dd").equals(day)).findFirst();
        return optional.get().getIsWorkDay();
    }

    public static Boolean dayIsWorkEnd(String day, List<WorkDayDTO> list){
        Optional<WorkDayDTO> optional = list.stream().filter(o-> DateUtil.millisToDateTime(o.getDate(), "yyyy-MM-dd").equals(day)).findFirst();
        return optional.get().getIsWeekEnd();
    }
}
